<template>
  <view class="container">
    <status-bar bgColor="#0088ff"></status-bar>
    
    <!-- 顶部导航栏 -->
    <view class="nav-bar">
      <view class="back-btn" @click="goBack">
        <image src="/static/images/icon/backward_flat.png" class="back-icon-img"></image>
      </view>
      <view class="nav-title">修改测量数据</view>
    </view>
    
    <!-- 表单内容 -->
    <scroll-view class="form-content" scroll-y="true">
      <!-- 房间照片 -->
      <view class="form-section">
        <text class="section-label">房间照片 ({{ formData.roomPhotos ? formData.roomPhotos.length : 0 }}/3)</text>
        <view class="photo-list">
          <!-- 已上传的照片 -->
          <view 
            class="photo-item" 
            v-for="(photo, index) in formData.roomPhotos" 
            :key="index"
          >
            <image :src="photo" class="photo-preview" mode="aspectFill"></image>
            <view class="photo-delete" @click="deletePhoto(index)" v-if="orderStatus != '5'">
              <text class="delete-icon">×</text>
            </view>
          </view>
          
          <!-- 上传按钮 -->
          <view 
            class="photo-uploader" 
            :class="{disabled: formData.roomPhotos.length >= 3}" 
            @click="uploadPhoto"
            v-if="formData.roomPhotos.length < 3 &&orderStatus != '5'"
          >
            <view class="photo-placeholder" >
              <image src="/static/images/icon/camera.png" class="camera-icon"></image>
              <text class="upload-text">点击上传</text>
            </view>
          </view>
        </view>
        
        <view class="photo-tip" v-if="formData.roomPhotos.length >= 3">
          <text>最多上传3张照片</text>
        </view>
      </view>
      
      <!-- 房间名称 -->
      <view class="form-item">
        <text class="item-label">房间名称<text class="required">*</text></text>
        <view class="item-value">
          <input v-model="formData.roomNo" class="value-text" placeholder="请输入或选择" style="text-align: right; flex: 1;"/>
          <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon" @click="selectRoomName"></image>
        </view>
      </view>
      
      <!-- 窗户类型 -->
      <view class="form-item">
        <text class="item-label">窗户类型<text class="required">*</text></text>
        <view class="item-value" @click="selectWindowType">
          <text class="value-text" :class="{ placeholder: !formData.windowTypeName }">
            {{ formData.windowTypeName || '' }}
          </text>
          <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
        </view>
      </view>
      
      <!-- 安装面 -->
      <view class="form-item">
        <text class="item-label">安装面材质<text class="required">*</text></text>
        <view class="item-value" @click="selectInstallSurface">
          <text class="value-text" :class="{ placeholder: !formData.installSurfaceName }">
            {{ formData.installSurfaceName || '' }}
          </text>
          <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
        </view>
      </view>
      
      <!-- 安装场景 -->
      <view class="form-item">
        <text class="item-label">安装场景</text>
        <view class="item-value" @click="selectInstallScene">
          <text class="value-text" :class="{ placeholder: !formData.installSceneName }">
            {{ formData.installSceneName || '窗帘盒' }}
          </text>
          <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
        </view>
      </view>

      
      <!-- 尺寸测量模块 -->
      <view class="measurement-module" v-if="formData.installSceneName">
        <view class="module-header">
          <text class="module-title">尺寸测量</text>
        </view>
        
        <view class="form-item" v-if="formData.installSceneName != '窗帘盒'">
          <text class="item-label">{{ getInstallSceneDes() }}</text>
          <view class="item-value">
            <input 
              class="measurement-input" 
              type="digit" 
              v-model="formData.otherDistance" 
              placeholder="0.00"
            />
            <text class="input-unit">米</text>
            <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
          </view>
        </view>
        
        <view class="form-item" v-if="formData.installSceneName === '窗帘盒'" >
          <text class="item-label">窗帘盒宽度</text>
          <view class="item-value">
            <input 
              class="measurement-input" 
              type="digit" 
              v-model="formData.boxWidth" 
              placeholder="0.00"
            />
            <text class="input-unit">米</text>
            <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
          </view>
        </view>
        
        <view class="form-item" v-if="formData.installSceneName === '窗帘盒'">
          <text class="item-label">窗帘盒高度</text>
          <view class="item-value">
            <input 
              class="measurement-input" 
              type="digit" 
              v-model="formData.boxHeight" 
              placeholder="0.00"
            />
            <text class="input-unit">米</text>
            <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
          </view>
        </view>
      </view>
	  
      
      <!-- 产品名称 -->
      <view class="form-item">
        <text class="item-label">产品名称<text class="required">*</text></text>
        <view class="item-value" @click="selectProductName">
          <text class="value-text" :class="{ placeholder: !formData.productName }">
            {{ formData.productName || '' }}
          </text>
          <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
        </view>
      </view>

      <!-- 弯轨参数（仅在选择弯轨时显示） -->
      <view class="curved-rail-module" v-if="formData.leftSizeShow || formData.rightSizeShow || formData.frontSizeShow " >
        <view class="module-header">
          <text class="module-title">弯轨参数-人面对窗户时各方向尺寸</text>
        </view>
        
        <view class="form-item" v-if="formData.leftSizeShow">
          <text class="item-label">左边</text>
          <view class="item-value">
            <input 
              class="measurement-input" 
              type="digit" 
              v-model="formData.leftSize" 
              placeholder="0.00"
            />
            <text class="input-unit">米</text>
            <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
          </view>
        </view>
        
        <view class="form-item" v-if="formData.rightSizeShow">
          <text class="item-label">右边</text>
          <view class="item-value">
            <input 
              class="measurement-input" 
              type="digit" 
              v-model="formData.rightSize" 
              placeholder="0.00"
            />
            <text class="input-unit">米</text>
            <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
          </view>
        </view>
        
        <view class="form-item" v-if="formData.frontSizeShow">
          <text class="item-label">正面</text>
          <view class="item-value">
            <input 
              class="measurement-input" 
              type="digit" 
              v-model="formData.frontSize" 
              placeholder="0.00"
            />
            <text class="input-unit">米</text>
            <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
          </view>
        </view>
      </view>




      
      <!-- 驱动方式 -->
      <view class="form-item">
        <text class="item-label">驱动方式</text>
        <view class="button-group">
          <button 
            class="option-btn" 
            :class="{ active: formData.driveMode === '手动' }"
            @click="selectDriveMode('手动')"
          >
            手动
          </button>
          <button 
            class="option-btn" 
            :class="{ active: formData.driveMode === '电动' }"
            @click="selectDriveMode('电动')"
          >
            电动
          </button>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>
      
      <!-- 电动配置模块（仅在选择电动时显示） -->
      <view class="electric-config-module" v-if="formData.driveMode === '电动'">
        <view class="module-header">
          <text class="module-title">电动配置</text>
        </view>
        
        <!-- 电源方向 -->
        <view class="form-item">
          <text class="item-label">电源方向</text>
          <view class="button-group">
            <button 
              class="option-btn" 
              :class="{ active: formData.powerDirection === '在左' }"
              @click="selectPowerDirection('在左')"
            >
              在左
            </button>
            <button 
              class="option-btn" 
              :class="{ active: formData.powerDirection === '在右' }"
              @click="selectPowerDirection('在右')"
            >
              在右
            </button>
          </view>
          <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
        </view>
        
        <!-- 距顶高度 -->
        <view class="form-item">
          <text class="item-label">距顶高度<text class="required">*</text></text>
          <view class="input-group">
            <input 
              class="number-input" 
              type="number" 
              v-model="formData.topHeight" 
              placeholder=""
            />
            <text class="unit">米</text>
          </view>
          <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
        </view>
      </view>
      
      <!-- 层数 -->
      <view class="form-item" v-if="formData.productName !== '成品帘'">
        <text class="item-label">层数</text>
        <view class="button-group">
          <button 
            class="option-btn" 
            :class="{ active: formData.layers === '单层' }"
            @click="selectLayers('单层')"
          >
            单层
          </button>
          <button 
            class="option-btn" 
            :class="{ active: formData.layers === '双层' }"
            @click="selectLayers('双层')"
          >
            双层
          </button>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>
      
      <!-- 开合方式 -->
      <view class="form-item" v-if="formData.productName !== '成品帘'">
        <text class="item-label">开合方式</text>
        <view class="button-group">
          <button 
            class="option-btn" 
            :class="{ active: formData.openMode === '双开' }"
            @click="selectOpenMode('双开')"
          >
            双开
          </button>
          <button 
            class="option-btn" 
            :class="{ active: formData.openMode === '单开' }"
            @click="selectOpenMode('单开')"
          >
            单开
          </button>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>
      
      <!-- 开合方向 -->
      <view class="form-item" v-if="formData.openMode == '单开'">
        <text class="item-label">开合方向</text>
        <view class="button-group">
          <button 
            class="option-btn" 
            :class="{ active: formData.openDirection === '向左开' }"
            @click="selectOpenDirection('向左开')"
          >
            向左开
          </button>
          <button 
            class="option-btn" 
            :class="{ active: formData.openDirection === '向右开' }"
            @click="selectOpenDirection('向右开')"
          >
            向右开
          </button>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>
      
      <!-- 安装方式 -->
      <view class="form-item">
        <text class="item-label">安装方式</text>
        <view class="item-value" @click="selectInstallMethod">
          <text class="value-text" :class="{ placeholder: !formData.installMethod }">
            {{ formData.installMethod || '请选择安装方式' }}
          </text>
          <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
        </view>
      </view>

      <!-- 宽度测量 -->
      <view class="form-item"  >
        <text class="item-label">宽度</text>
        <view class="measurement-data-row">
          <view class="type-selector" @click="selectWidthType">
            <text class="type-text" :class="{ placeholder: !formData.widthType }">
              {{ formData.widthType || '选择类型' }}
            </text>
          </view>
          <view class="data-input">
            <input v-if="!formData.frontSizeShow && !formData.leftSizeShow && !formData.rightSizeShow" class="measurement-input"  type="digit" v-model="formData.widthValue" placeholder="0.00" />
            <text  v-else class="placeholder">{{ curvedWidthSum }}</text>
            <text class="input-unit">米</text>
          </view>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>





      <!-- 高度测量 -->
      <view class="form-item" >
        <text class="item-label">高度</text>
        <view class="measurement-data-row">
          <view class="type-selector" @click="selectHeightType">
            <text class="type-text" :class="{ placeholder: !formData.heightType }">
              {{ formData.heightType || '选择类型' }}
            </text>
          </view>
          <view class="data-input">
            <input 
              class="measurement-input" 
              type="digit" 
              v-model="formData.heightValue" 
              placeholder="0.00"
            />
            <text class="input-unit">米</text>
          </view>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>

      <!-- 窗帘离地高度 -->
      <view class="form-item" >
        <text class="item-label">窗帘离地高度</text>
        <view class="ground-height-options">
          <button 
            class="option-btn-mobile" 
            :class="{ active: formData.groundHeightType === '和客户沟通' }"
            @click="selectGroundHeightType('和客户沟通')"
          >
            和客户沟通
          </button>
          <button 
            class="option-btn-mobile" 
            :class="{ active: formData.groundHeightType === '输入测量高度' }"
            @click="selectGroundHeightType('输入测量高度')"
          >
            输入
          </button>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>

      <!-- 测量高度输入（仅在选择输入测量高度时显示） -->
      <view class="form-item" v-if="formData.groundHeightType === '输入测量高度'">
        <text class="item-label">测量高度</text>
        <view class="input-group">
          <input 
            class="number-input" 
            type="digit" 
            v-model="formData.groundHeightValue" 
            placeholder="0.00"
          />
          <text class="unit">米</text>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>

      <!-- 是否有窗幔 -->
      <view class="form-item">
        <text class="item-label">是否有窗幔</text>
        <view class="valance-options">
          <button 
            class="option-btn-mobile" 
            :class="{ active: formData.hasValance === '是' }"
            @click="selectValance('是')"
          >
            是
          </button>
          <button 
            class="option-btn-mobile" 
            :class="{ active: formData.hasValance === '否' }"
            @click="selectValance('否')"
          >
            否
          </button>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>




      <!-- 幔轨实际尺寸（仅在选择有窗幔时显示） -->
      <view class="form-item" v-if="formData.hasValance === '是'">
        <text class="item-label">幔轨实际尺寸</text>
        <view class="input-group">
          <input 
            class="number-input" 
            type="digit" 
            v-model="formData.valanceSize" 
            placeholder="0.00"
          />
          <text class="unit">米</text>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>

      <!-- 是否内开窗 -->
      <view class="form-item">
        <text class="item-label">是否内开窗</text>
        <view class="inward-window-options">
          <button 
            class="option-btn-mobile" 
            :class="{ active: formData.hasInwardWindow === '是' }"
            @click="selectInwardWindow('是')"
          >
            是
          </button>
          <button 
            class="option-btn-mobile" 
            :class="{ active: formData.hasInwardWindow === '否' }"
            @click="selectInwardWindow('否')"
          >
            否
          </button>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>

      <!-- 内开窗距离（仅在选择是内开窗时显示） -->
      <view class="form-item" v-if="formData.hasInwardWindow === '是'">
        <text class="item-label">上沿到安装位置距离</text>
        <view class="input-group">
          <input 
            class="number-input" 
            type="digit" 
            v-model="formData.inwardWindowDistance" 
            placeholder="0.00"
          />
          <text class="unit">米</text>
        </view>
        <image src="/static/images/icon/arrow_right_gray.png" class="arrow-icon"></image>
      </view>

      <!-- 特殊需求 -->
      <view class="special-requirements-module">
        <view class="module-header">
          <text class="module-title">特殊需求</text>
        </view>
        
        <!-- 选项按钮 -->
        <view class="requirement-options">
            <button v-for="(item, index) in specialDemands" :key="index" class="requirement-option-btn" @click="addRequirement(item.value)">
						{{ item.label }}
				  	</button>
        </view>
        
        <!-- 文本域输入 -->
        <view class="requirement-textarea">
          <textarea 
            class="special-textarea" 
            v-model="formData.specialRequirements" 
            placeholder="点击上方选项添加特殊需求..."
            maxlength="200"
          ></textarea>
        </view>
      </view>
    </scroll-view>
    
    <!-- 底部按钮 -->
    <view class="bottom-actions">
      <button class="submit-btn" @click="submitData">提交</button>
    </view>
  </view>
</template>

<script>
import { allSystemParamConfig } from '@/api/app/master/common'
import { getRoomNos, addOrderData } from '@/api/app/master/order'
import { uploadImgs } from '@/utils/picService'
import {
		uploadFile
	} from '@/api/app/master/file'

export default {
  data() {
    return {
      formData: {
		id:'',
        roomPhotos: [],
        roomNo: '',
		windowType: '',
        windowTypeName: '',
        installSurface: '',
		installSurfaceName: '',
        installScene: '4',
		installSceneName: '窗帘盒',
		productType: '',
        productName: '',
        driveMode: '手动',
        powerDirection: '在左',
        topHeight: '',
        layers: '双层',
        openMode: '双开',
        openDirection: '向左开',
        installMethod: '',
		installMethodVal: '',
        // 尺寸测量数据
        otherDistance: '',
        boxWidth: '',
        boxHeight: '',
        // 弯轨参数
        leftSize: '',
        rightSize: '',
        frontSize: '',
        
        frontSizeShow: false,
        leftSizeShow: false, 
        rightSizeShow: false,

        // 宽度和高度测量数据
        widthType: '',
		widthSizeType: '',
        widthValue: '',
		heightSizeType : '',
        heightType: '',
        heightValue: '',
        // 窗帘离地高度
        groundHeightType: '',
        groundHeightValue: '',
        // 窗幔相关
        hasValance: '',
        valanceSize: '',
        // 内开窗相关
        hasInwardWindow: '否',
        inwardWindowDistance: '',
        // 特殊需求
        specialRequirements: ''
      },
      orderStatus: undefined,
      // 系统配置信息
      sysParamConfigs: [],
      // 处理后的配置数据
      projectNames: [],
      specialWalls: [],
      curtainsTypes: [],
      measureProjects: [],
      measureTypes: [],
      additionalChildFees: [],
      additionalFees: [],
	  windowTypes: [],
	  installSurfaceTypes: [],
	  installScenarios:[],
	  widthSizeTypes:[],
	  heightSizeTypes:[],
      // 房间名称列表
      roomNames: [],
	  actionState: false,
	  orderNo:'',
	  orderStatus:'',
    specialDemands: [],
				selectedSpecialDemands:[],
    }
  },
  
  onLoad(options) {
	  if(options.orderNo) {
	  	this.orderNo = options.orderNo;
	  	this.orderStatus = options.orderStatus;
	  }

    if(options.orderStatus) {
	  	this.orderStatus = options.orderStatus;
      console.log('拿到订单的状态',this.orderStatus)
	  }

	  if (options.configs) {
	  	this.sysParamConfigs = JSON.parse(decodeURIComponent(options.configs));
		// 获取系统配置信息
		this.getAllSystemParamConfig();
	  }
	if(options.data) {
		const data = JSON.parse(decodeURIComponent(options.data));
		if(data) {
			this.formData.id = data.id;
          var picArr = [];
						if(data.dataPicture){
							var splitPic = data.dataPicture.split('#@@#');
							console.log(splitPic)
							splitPic.forEach(item=>{
								var tempArr = item.split('@##@');
								picArr.push(tempArr[1]	);
							})
              
						}
						this.formData.roomPhotos = picArr;
        if (!this.formData.roomPhotos ) {this.formData.roomPhotos  = []}





			// this.formData.roomPhotos = data.dataPicture ? data.dataPicture.split("#@@#") : [] ;


			this.formData.roomNo = data.roomNo || '';
			this.formData.windowType = data.windowType || '';
			const windowType = this.windowTypes.find(item => item.value === data.windowType);
			this.formData.windowTypeName = windowType?.label || '';
			this.formData.installSurface = data.installSurfaceType || '';
			const installSurface = this.installSurfaceTypes.find(item => item.value === data.installSurfaceType);
			this.formData.installSurfaceName = installSurface?.label || '';
			this.formData.installScene = data.installScenario || '4';
			const installScene = this.installScenarios.find(item => item.value === data.installScenario);
			this.formData.installSceneName = installScene?.label || '窗帘盒';
			// 尺寸测量数据
			this.formData.boxWidth = data.boxWidth || '';
			this.formData.boxHeight = data.boxHeight || '';
			this.formData.otherDistance = data.otherDistance || '';
			
			this.formData.productType = data.productType || '';
			this.formData.productName = this.getProductName(data.productType) || '';
			// 弯轨参数
			this.formData.leftSize = data.leftSize || '';
			this.formData.rightSize = data.rightSize || '';
			this.formData.frontSize = data.frontSize || '';
			
			this.formData.driveMode = data.propelWay === '31'?'手动':'电动';
			this.formData.powerDirection = data.powerDirection === '1'?'在左':'在右';
			this.formData.topHeight = data.powerDistance || '';
			this.formData.layers = data.plies === '2'?'双层':'单层';
			this.formData.openMode = data.openWay === '1'?'双开':'单开';
			this.formData.openDirection = data.openDirection === '1'?'向左开':'向右开';
			this.generateInstallMethod();
			this.formData.installMethodVal = data.installWay || '';
			const measureType = this.measureTypes.find(item => item.value === data.installWay);
			this.formData.installMethod = measureType?.label || '';	
			// 宽度和高度测量数据
			this.formData.widthSizeType = data.widthSizeType || '';
			const widthTypes = [];
			for (let i = 0; i < this.widthSizeTypes.length; i++) {
			  if (this.getInstallScenario(data.installScenario) === this.widthSizeTypes[i].parentName) {
			    widthTypes.push(this.widthSizeTypes[i]);
			  }
			}
			const widthType = widthTypes.find(item => item.value === data.widthSizeType);
			this.formData.widthType = widthType?.label || '';
			this.formData.widthValue = data.windowWidth || '';
			this.formData.heightSizeType = data.heightSizeType || '';
			const heightTypes = [];
			 //根据安装场景加载高度尺寸类型
			for (let i = 0; i < this.heightSizeTypes.length; i++) {
			  if (this.getInstallScenario(data.installScenario) === this.heightSizeTypes[i].parentName) {
			    heightTypes.push(this.heightSizeTypes[i]);
			  }
			}
			const heightType = heightTypes.find(item => item.value === data.heightSizeType);
			this.formData.heightType = heightType?.label || '';
			this.formData.heightValue = data.windowHeight || '';
			// 窗帘离地高度
      console.log(data.curtainGround)
      if (data.curtainGround && data.curtainGround !== '1') {
        this.formData.groundHeightType = "输入测量高度"  ;
      }else{
         this.formData.groundHeightType = "和客户沟通"  ;
      }


			this.formData.groundHeightValue = data.curtainGroundDistance || '';
			// 窗幔相关
			this.formData.hasValance = data.isCurtains === '2'?'是':(data.isCurtains === '1'?'否':'');
			this.formData.valanceSize = data.curtainsTrackSize || '';
			// 内开窗相关
			this.formData.hasInwardWindow= data.isOpenInside === '2'?'是':(data.isOpenInside === '1'?'否':'');
			this.formData.inwardWindowDistance = data.upperEdgeDistance || '';
			// 特殊需求
			this.formData.specialRequirements = data.specialDemand || '';



      this.processFrontLeftRight();
      
		}
	}
    // 获取房间名称列表
    this.getRoomNames();
  },
  
  onUnload() {
  	const eventChannel = this.getOpenerEventChannel();
  	eventChannel.emit('backFromAction', this.actionState);
  },
  computed: {
			curvedWidthSum() {
				const toNumber = (value) => {
					const num = parseFloat(value);
					return isNaN(num) ? 0 : num;
				};
				const { leftSize, rightSize, frontSize } = this.formData || {};
        this.formData.widthValue = toNumber(leftSize) + toNumber(rightSize) + toNumber(frontSize);
				return toNumber(leftSize) + toNumber(rightSize) + toNumber(frontSize);
			}
		},
  
  methods: {
    // 获取系统配置信息
    getAllSystemParamConfig() {
        // 处理所有类型的数据
        this.projectNames = [];
        this.specialWalls = [];
        this.curtainsTypes = [];
        this.measureProjects = [];
        this.measureTypes = [];
        this.additionalChildFees = [];
        this.additionalFees = [];

        this.specialDemands = [];

		for (let i = 0; i < this.sysParamConfigs.length; i++) {
		  let tempConfig = this.sysParamConfigs[i];
		  // 产品名称
		  if (tempConfig.parentSign === 'productType') {
		    this.projectNames.push({
		      value: tempConfig.paramValue,
		      label: tempConfig.paramName
		    });
		  }
		  // 特殊墙体
		  if (tempConfig.parentSign === 'specialWall') {
		    this.specialWalls.push({
		      value: tempConfig.paramValue,
		      label: tempConfig.paramName
		    });
		  }
		  // 窗帘类型
		  if (tempConfig.parentSign === 'curtainsType') {
		    this.curtainsTypes.push({
		      value: tempConfig.paramValue,
		      label: tempConfig.paramName
		    });
		  }
		  // 测量项目
		  if (tempConfig.parentSign === 'measureProject') {
		    this.measureProjects.push({
		      value: tempConfig.paramValue,
		      label: tempConfig.paramName
		    });
		  }
		//   // 测量类型
		//   if (tempConfig.parentSign === 'measureType') {
		//     this.measureTypes.push({
		//       value: tempConfig.paramValue,
		//       label: tempConfig.paramName
		//     });
		//   }
		//窗户类型
		  if (tempConfig.parentSign === 'windowType') {
		    this.windowTypes.push({
		      value: tempConfig.paramSign,
		      label: tempConfig.paramName
		    });
		  }
		
		  //安装面材质
		  if (tempConfig.parentSign === 'installSurfaceType') {
		    this.installSurfaceTypes.push({
		      value: tempConfig.paramValue,
		      label: tempConfig.paramName
		    });
		  }
		
		  //安装场景
		  if (tempConfig.parentSign === 'installScenario') {
		    this.installScenarios.push({
		      value: tempConfig.paramValue,
		      label: tempConfig.paramName
		    });
		  }
		
		//宽度尺寸类型
		  if (tempConfig.parentSign === 'widthSizeType') {
		    for (let j = 0; j < this.sysParamConfigs.length; j++) {
		      let tempConfigChild = this.sysParamConfigs[j];
		      if (tempConfigChild.parentSign !== tempConfig.paramSign) {
		        continue;
		      }
		      this.widthSizeTypes.push({
		        parentSign: tempConfig.paramSign,
		        parentName: tempConfig.paramName,
		        value: tempConfigChild.paramValue,
		        label: tempConfigChild.paramName
		      });
		    }
		  }
		  //高度尺寸类型
		  if (tempConfig.parentSign === 'heightSizeType') {
		    for (let j = 0; j < this.sysParamConfigs.length; j++) {
		      let tempConfigChild = this.sysParamConfigs[j];
		      if (tempConfigChild.parentSign !== tempConfig.paramSign) {
		        continue;
		      }
		      this.heightSizeTypes.push({
		        parentSign: tempConfig.paramSign,
		        parentName: tempConfig.paramName,
		        value: tempConfigChild.paramValue,
		        label: tempConfigChild.paramName
		      });
		    }
		  }	

        if (tempConfig.parentSign === 'specialDemand') {
						this.specialDemands.push({
							key: tempConfig.paramSign,
							value: tempConfig.paramValue,
							label: tempConfig.paramName
						});
					}

		}
    },
    
    // 获取房间名称列表
    getRoomNames() {
      getRoomNos().then(response => {
        if (response.code === 200) {
           this.roomNames = response.data.filter(item=>item!=null&&item!='null') || [];
        } else {
          console.error('获取房间名称失败:', response.msg);
          // 如果接口失败，使用默认房间名称
          this.roomNames = ['客厅', '主卧', '次卧', '厨房', '卫生间', '书房', '阳台'];
        }
      }).catch(err => {
        console.error('获取房间名称失败:', err);
        // 如果接口失败，使用默认房间名称
        this.roomNames = ['客厅', '主卧', '次卧', '厨房', '卫生间', '书房', '阳台'];
      });
    },
    

	getInstallSceneDes(){
		if(this.formData.installScene == ''){
			return '';
		}	
		if( this.formData.installSceneName == '石膏线'){
			return '石膏线下到窗户上沿的距离'; 
		}

		if(this.formData.installSceneName == '框内安装' ){
			return '框内安装面宽度(里面)'; 
		}
		if(this.formData.installSceneName == '大白墙' ){
			return '房顶下沿到窗框上沿距离'; 
		}

   

	},

  processFrontLeftRight() {

        this.formData.frontSizeShow = false;
        this.formData.leftSizeShow = false;
        this.formData.rightSizeShow = false;

      const windowName = this.getWindowType(this.formData.windowType)
      
      const productName = this.formData.productName;
      console.log(windowName , productName);
      if (productName.indexOf("弯轨") > -1) {
        // if (windowName.indexOf("左L") > -1) {
					// 	this.formData.frontSizeShow = true;
					// 	this.formData.leftSizeShow = true;
					// 	this.formData.rightSizeShow = false;
					// } else if (windowName.indexOf("右L") > -1) {
					// 	this.formData.frontSizeShow = true;
					// 	this.formData.rightSizeShow = true;
					// 	this.formData.leftSizeShow = false;
					// } else if (windowName.indexOf("U") > -1) {
					// 	this.formData.frontSizeShow = true;
					// 	this.formData.leftSizeShow = true;
					// 	this.formData.rightSizeShow = true;
					// }

					  this.formData.frontSizeShow = true;
						this.formData.leftSizeShow = true;
						this.formData.rightSizeShow = true;

      } else {
        this.formData.frontSizeShow = false;
        this.formData.leftSizeShow = false;
        this.formData.rightSizeShow = false;
      }
    },


    // 返回上一页
    goBack() {
      uni.navigateBack();
    },
    
    // 上传照片
    uploadPhoto() {
      if (this.formData.roomPhotos && this.formData.roomPhotos.length >= 3) {
        uni.showToast({
          title: '最多上传3张照片',
          icon: 'none'
        });
        return;
      }
      
      const remainCount = 3 - (this.formData.roomPhotos ? this.formData.roomPhotos.length : 0);
      uni.chooseImage({
					count: remainCount,
					sizeType: ['compressed'],
					sourceType: ['album', 'camera'],
					success: async (res) => {
						console.log('选择照片成功:', res);

						if (!this.formData.roomPhotos) {
							this.formData.roomPhotos = []
						}

						uni.showLoading({
							title: '正在上传照片...'
						})

						try {
							const uploadPromises = res.tempFilePaths.map(async (filePath) => {
								// 生成唯一文件名
								const timestamp = Date.now()
								const random = Math.random().toString(36).substring(2, 8)
								const fileName = `measure_photos/${timestamp}_${random}.jpg`
								return await uploadFile(fileName, filePath)
							})

							// 等待所有照片上传完成
							const uploadedUrls = await Promise.all(uploadPromises).then(results => {
								return results.map(result => result.url);
							})
							console.log('上传结果:', uploadedUrls)

							// 更新照片列表
							this.formData.roomPhotos = [...this.formData.roomPhotos, ...uploadedUrls]

							uni.hideLoading()
							uni.showToast({
								title: '上传成功',
								icon: 'success'
							})

						} catch (error) {
							console.error('上传失败:', error)
							uni.hideLoading()
							uni.showToast({
								title: '上传失败，请重试',
								icon: 'none'
							})
						}
					},
					fail: (error) => {
						console.error('选择照片失败:', error)
						uni.showToast({
							title: '选择照片失败',
							icon: 'none'
						})
					}
				})
   
    },
    
    // 删除照片
    deletePhoto(index) {
      this.formData.roomPhotos.splice(index, 1);
    },
    
    // 选择房间名称
    selectRoomName() {
      if (this.roomNames.length === 0) {
        uni.showToast({
          title: '房间数据加载中',
          icon: 'none'
        });
        return;
      }
      
      uni.showActionSheet({
        itemList: this.roomNames,
        success: (res) => {
          this.formData.roomNo = this.roomNames[res.tapIndex];
        }
      });
    },
    getWindowType(value) {
      const item = this.windowTypes.find(item => item.value === value);
      return item ? item.label : '未知';
    },
    // 选择窗户类型
    selectWindowType() {
      if (this.windowTypes.length === 0) {
        return;
      }
      const typeNames = this.windowTypes.map(item => item.label);
	   const types = this.windowTypes.map(item => item.value);
      uni.showActionSheet({
        itemList: typeNames,
        success: (res) => {
          this.formData.windowTypeName = typeNames[res.tapIndex];
		   this.formData.windowType = types[res.tapIndex];
		  console.log(this.formData.windowType, this.formData.windowTypeName);

          this.processFrontLeftRight();

        }
      });
    },
    
    // 选择安装面
    selectInstallSurface() {
      
      const surfacesName = this.installSurfaceTypes.map(item => item.label);
	  const surfaces = this.installSurfaceTypes.map(item => item.value);
      uni.showActionSheet({
        itemList: surfacesName,
        success: (res) => {
		  this.formData.installSurfaceName = surfacesName[res.tapIndex];
          this.formData.installSurface = surfaces[res.tapIndex];
		  console.log(this.formData.installSurface, this.formData.installSurfaceName);
        }
      });
    },
    
    // 选择安装场景
    selectInstallScene() {
      const scenesName = this.installScenarios.map(item => item.label);
	   const scenes = this.installScenarios.map(item => item.value);
      uni.showActionSheet({
        itemList: scenesName,
        success: (res) => {
          this.formData.installScene = scenes[res.tapIndex];
		  this.formData.installSceneName = scenesName[res.tapIndex];
        }
      });
	},
    
    // 选择产品名称
    selectProductName() {
      if (this.projectNames.length === 0) {
        uni.showToast({
          title: '配置数据加载中',
          icon: 'none'
        });
        return;
      }
      const products = this.projectNames.map(item => item.label);
     const productTypes = this.projectNames.map(item => item.value);
	  uni.showActionSheet({
        itemList: products,
        success: (res) => {
			this.formData.productType = productTypes[res.tapIndex];
          this.formData.productName = products[res.tapIndex];
          this.processFrontLeftRight();
        }
      });
    },
    
	getProductName(value) {
      const item = this.projectNames.find(item => item.value === value);
      return item ? item.label : '未知';
    },
    // 生成安装方式
    generateInstallMethod() {
      this.measureTypes = [
        {
          value: "1",
          label: "顶装"
        },
        {
          value: "2",
          label: "侧装"
        }
      ];
      let productName = this.getProductName(this.formData.productType);
      if (productName.indexOf("梦幻帘") > -1 ||
        productName.indexOf("百叶帘") > -1 ||
        productName.indexOf("卷帘") > -1 ||
        productName.indexOf("香格里拉帘") > -1 ||
        productName.indexOf("柔纱帘") > -1 ||
        productName.indexOf("斑马帘") > -1 ||
        productName.indexOf("罗马帘") > -1 ||
        productName.indexOf("木百叶") > -1 ||
        productName.indexOf("蜂巢帘") > -1) {
        this.measureTypes.push({
          value: "4",
          label: "两头安装"
        });
        this.measureTypes.push({
          value: "5",
          label: "免打孔"
        });
      } else {
        this.measureTypes.push({
          value: "3",
          label: "已安装"
        });
      }
    },
	selectInstallMethod() {
	  this.measureTypes = [
	    {
	      value: "1",
	      label: "顶装"
	    },
	    {
	      value: "2",
	      label: "侧装"
	    }
	  ];
	  let productName = this.getProductName(this.formData.productType);
	  if (productName.indexOf("梦幻帘") > -1 ||
	    productName.indexOf("百叶帘") > -1 ||
	    productName.indexOf("卷帘") > -1 ||
	    productName.indexOf("香格里拉帘") > -1 ||
	    productName.indexOf("柔纱帘") > -1 ||
	    productName.indexOf("斑马帘") > -1 ||
	    productName.indexOf("罗马帘") > -1 ||
	    productName.indexOf("木百叶") > -1 ||
	    productName.indexOf("蜂巢帘") > -1) {
	    this.measureTypes.push({
	      value: "4",
	      label: "两头安装"
	    });
	    this.measureTypes.push({
	      value: "5",
	      label: "免打孔"
	    });
	  } else {
	    this.measureTypes.push({
	      value: "3",
	      label: "已安装"
	    });
	  }
	  
	  const methods = this.measureTypes.map(item => item.label);
	   const methodValues = this.measureTypes.map(item => item.value);
	  uni.showActionSheet({
	    itemList: methods,
	    success: (res) => {
	      this.formData.installMethod = methods[res.tapIndex];
		      this.formData.installMethodVal = methodValues[res.tapIndex];
	    }
	  });
	},

    // 选择宽度类型
    selectWidthType() {
     	const types = [];
	   //根据安装场景加载高度尺寸类型
      for (let i = 0; i < this.widthSizeTypes.length; i++) {
        if (this.getInstallScenario(this.formData.installScene) === this.widthSizeTypes[i].parentName) {
          types.push(this.widthSizeTypes[i]);
        }
      }

	  const methods = types.map(item => item.label);
	  const methodsValues = types.map(item => item.value);
      uni.showActionSheet({
        itemList: methods,
        success: (res) => {
			this.formData.widthSizeType = methodsValues[res.tapIndex];
          this.formData.widthType = methods[res.tapIndex];
        }
      });
    },

	getInstallScenario(value) {
      const item = this.installScenarios.find(item => item.value === value);
      return item ? item.label : '未知';
    },

    // 选择高度类型
    selectHeightType() {

		const types = [];
	   //根据安装场景加载高度尺寸类型
      for (let i = 0; i < this.heightSizeTypes.length; i++) {
        if (this.getInstallScenario(this.formData.installScene) === this.heightSizeTypes[i].parentName) {
          types.push(this.heightSizeTypes[i]);
        }
      }

	  const methods = types.map(item => item.label);
	   const methodValues = types.map(item => item.value);

      uni.showActionSheet({
        itemList: methods,
        success: (res) => {
          this.formData.heightType = methods[res.tapIndex];
		  this.formData.heightSizeType = methodValues[res.tapIndex];
        }
      });
    },

    // 选择窗帘离地高度类型
    selectGroundHeightType(type) {
      this.formData.groundHeightType = type;
      // 如果选择"和客户沟通"，清空测量高度值
      if (type === '和客户沟通') {
        this.formData.groundHeightValue = '';
      }
    },

    // 选择是否有窗幔
    selectValance(hasValance) {
      this.formData.hasValance = hasValance;
      // 如果选择"否"，清空幔轨尺寸值
      if (hasValance === '否') {
        this.formData.valanceSize = '';
      }
    },

    // 选择是否内开窗
    selectInwardWindow(hasInwardWindow) {
      this.formData.hasInwardWindow = hasInwardWindow;
      // 如果选择"否"，清空内开窗距离值
      if (hasInwardWindow === '否') {
        this.formData.inwardWindowDistance = '';
      }
    },

    // 添加特殊需求选项到文本域
			addRequirement(requirement) {
				const includ = this.formData.specialRequirements.includes(requirement);
				console.log(includ);
				if (!includ) {
					this.selectedSpecialDemands.push(requirement);
				} else {	
					this.selectedSpecialDemands = this.selectedSpecialDemands.filter(i => i !== requirement);
				}

				this.formData.specialRequirements =	this.selectedSpecialDemands.join('\r\n');

			},
    
    // 选择驱动方式
    selectDriveMode(mode) {
      this.formData.driveMode = mode;
    },
    
    // 选择电源方向
    selectPowerDirection(direction) {
      this.formData.powerDirection = direction;
    },
    
    // 选择层数
    selectLayers(layers) {
      this.formData.layers = layers;
    },
    
    // 选择开合方式
    selectOpenMode(mode) {
      this.formData.openMode = mode;
    },
    
    // 选择开合方向
    selectOpenDirection(direction) {
      this.formData.openDirection = direction;
    },
    
    // 提交数据
    submitData() {
      if (this.orderStatus === '5'){
        uni.showToast({
          title: '已完成，不可修改，请联系客服修改！',
          icon: 'none'
        });
        return;
      }
      // 验证必填项
      if (!this.formData.roomNo) {
        uni.showToast({
          title: '请选择房间名称',
          icon: 'none'
        });
        return;
      }
      
	  if (!this.formData.driveMode) {
        uni.showToast({
          title: '请选择驱动方式',
          icon: 'none'
        });
        return;
      }
      if (!this.formData.windowTypeName) {
        uni.showToast({
          title: '请选择窗户类型',
          icon: 'none'
        });
        return;
      }
      
      if (!this.formData.installSurfaceName) {
        uni.showToast({
          title: '请选择安装面材质',
          icon: 'none'
        });
        return;
      }
      if (!this.formData.installSceneName) {
					uni.showToast({
						title: '请选择安装场景',
						icon: 'none'
					});
					return;
				}

        if (!this.formData.installMethod) {
					uni.showToast({
						title: '请选择安装方式',
						icon: 'none'
					});
					return;
				}

      if (!this.formData.productName) {
        uni.showToast({
          title: '请选择产品名称',
          icon: 'none'
        });
        return;
      }

						if (!this.formData.widthSizeType) {
							uni.showToast({
							title: '请选择宽度尺寸类型',
							icon: 'none'
							});
							return;
						}

				if (!this.formData.heightSizeType) {
					uni.showToast({
						title: '请选择高度尺寸类型',
						icon: 'none'
					});
					return;
				}     

        if (!this.formData.heightValue || this.formData.heightValue <= 0) {
                  uni.showToast({
                    title: '请填写高度',
                    icon: 'none'
                  });
                  return;
                }
              
        if (!this.formData.frontSizeShow && !this.formData.leftSizeShow && !this.formData.rightSizeShow) {
                  if (!this.formData.widthValue || this.formData.widthValue <= 0	) {
                    uni.showToast({
                      title: '请填写宽度',					
                      icon: 'none'
                    });
                    return;
                  }
                }	
          
                if (! this.formData.roomPhotos || this.formData.roomPhotos.length < 1) {
                    uni.showToast({
                      title: '请上传图片',					
                      icon: 'none'
                    });
                    return;
                  }


      uni.showLoading({
        title: '提交中...'
      });

      console.log(this.formData.roomPhotos);


        var picStr = '';
				for (var i = 0; i < this.formData.roomPhotos.length; i++) {
					picStr +=  (i+1)+'image.png'+'@##@'+this.formData.roomPhotos[i] + '#@@#'
				}
				picStr = picStr.substring(0,picStr.length-4);

      console.log('widthValue',this.formData.widthValue);

      const tempData={
		orderNo: this.orderNo,
		id : this.formData.id,
		// dataPicture: this.formData.roomPhotos ? this.formData.roomPhotos.join('@##@') : '',
    dataPicture: this.formData.roomPhotos ? picStr : '',    
		roomNo: this.formData.roomNo,
		windowType: this.formData.windowType,
		installSurfaceType: this.formData.installSurface,
		installScenario: this.formData.installScene,
		boxWidth: this.formData.boxWidth,
		boxHeight: this.formData.boxHeight,
		otherDistance: this.formData.otherDistance,
		productType: this.formData.productType,
		leftSize: this.formData.leftSize,
		rightSize: this.formData.rightSize,
		frontSize: this.formData.frontSize,
		propelWay: this.formData.driveMode == '手动' ? '31' : '32',
		powerDirection: this.formData.powerDirection == '在左' ? '1' : '2',
		powerDistance: this.formData.topHeight,
		plies: this.formData.layers == '单层' ? '1' : '2',
		openWay: this.formData.openMode == '单开' ? '2' : '1',
		openDirection: this.formData.openDirection == '向左开' ? '1' : '2',
		installWay: this.formData.installMethodVal ,
		widthSizeType: this.formData.widthSizeType,
		windowWidth: this.formData.widthValue,
		heightSizeType: this.formData.heightSizeType,
		windowHeight: this.formData.heightValue,
		curtainGround: this.formData.groundHeightType == '和客户沟通' ? '1' : '2',
		curtainGroundDistance: this.formData.groundHeightType == '和客户沟通' ? '0' : this.formData.groundHeightValue,
		isCurtains: this.formData.hasValance == '是' ? '2' : '1',
		curtainsTrackSize: this.formData.valanceSize,
		isOpenInside: this.formData.hasInwardWindow === '是' ? '2' : '1',
		upperEdgeDistance: this.formData.inwardWindowDistance,
		specialDemand: this.formData.specialRequirements

	  }
	//   console.log(tempData);


      // 调用 addOrderData API 提交测量数据
      addOrderData(tempData).then(response => {
        uni.hideLoading();
        
        if (response.code === 200) {
		  this.actionState = true;
          uni.showToast({
            title: '提交成功',
            icon: 'success'
          });
          
          setTimeout(() => {
            uni.navigateBack();
          }, 1500);
        } else {
          uni.showToast({
            title: response.msg || '提交失败',
            icon: 'none'
          });
        }
      }).catch(error => {
        uni.hideLoading();
        console.error('提交测量数据失败:', error);
        uni.showToast({
          title: '网络错误，请重试',
          icon: 'none'
        });
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  min-height: 100vh;
  background-color: #f5f5f5;
}

/* 顶部导航栏 */
.nav-bar {
  display: flex;
  align-items: center;
  height: 90rpx;
  background-color: #0088ff;
  color: #fff;
  padding: 0 30rpx;
  position: relative;
}

.back-btn {
  position: absolute;
  left: 30rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-icon-img {
  width: 40rpx;
  height: 40rpx;
}

.nav-title {
  flex: 1;
  text-align: center;
  font-size: 36rpx;
  font-weight: bold;
}

/* 表单内容 */
.form-content {
  padding: 20rpx;
  padding-bottom: 120rpx;
}

.form-section {
  margin-bottom: 30rpx;
}

.section-label {
  font-size: 28rpx;
  color: #666;
  margin-bottom: 20rpx;
  display: block;
}

/* 照片上传 */
.photo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 20rpx;
}

.photo-item {
  position: relative;
  width: 200rpx;
  height: 200rpx;
  border-radius: 12rpx;
  overflow: hidden;
}

.photo-preview {
  width: 100%;
  height: 100%;
  border-radius: 12rpx;
}

.photo-delete {
  position: absolute;
  top: 10rpx;
  right: 10rpx;
  width: 40rpx;
  height: 40rpx;
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-icon {
  color: #fff;
  font-size: 30rpx;
  font-weight: bold;
}

.photo-uploader {
  width: 200rpx;
  height: 200rpx;
  border: 2rpx dashed #ddd;
  border-radius: 12rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
}

.photo-uploader.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.camera-icon {
  width: 60rpx;
  height: 60rpx;
  opacity: 0.4;
  margin-bottom: 10rpx;
}

.upload-text {
  font-size: 24rpx;
  color: #999;
}

.photo-tip {
  margin-top: 20rpx;
  text-align: center;
}

.photo-tip text {
  font-size: 24rpx;
  color: #999;
}

/* 表单项 */
.form-item {
  background-color: #fff;
  border-radius: 12rpx;
  padding: 30rpx;
  margin-bottom: 20rpx;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.item-label {
  font-size: 28rpx;
  color: #333;
  width: 200rpx;
  flex-shrink: 0;
}

.required {
  color: #ff3b30;
}

.item-value {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  margin-right: 10rpx;
}

.value-text {
  font-size: 28rpx;
  color: #333;
}

.value-text.placeholder {
  color: #999;
}

.arrow-icon {
  width: 24rpx;
  height: 24rpx;
  opacity: 0.4;
  margin-left: 10rpx;
}

/* 按钮组 */
.button-group {
  display: flex;
  gap: 20rpx;
  flex: 1;
  justify-content: flex-end;
  margin-right: 10rpx;
}

.option-btn {
  width: 120rpx;
  height: 60rpx;
  line-height: 60rpx;
  text-align: center;
  border: 2rpx solid #e0e0e0;
  border-radius: 30rpx;
  background-color: #fff;
  color: #666;
  font-size: 26rpx;
}

.option-btn.active {
  border-color: #0088ff;
  background-color: #0088ff;
  color: #fff;
}

/* 输入组 */
.input-group {
  display: flex;
  align-items: center;
  gap: 10rpx;
  flex: 1;
  justify-content: flex-end;
  margin-right: 10rpx;
}

.number-input {
  width: 200rpx;
  height: 60rpx;
  padding: 0 15rpx;
  border: 2rpx solid #e0e0e0;
  border-radius: 8rpx;
  font-size: 28rpx;
  background-color: #fff;
  text-align: right;
}

.unit {
  font-size: 28rpx;
  color: #666;
}

/* 底部按钮 */
.bottom-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #fff;
  padding: 20rpx 30rpx;
  border-top: 1rpx solid #f0f0f0;
  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.submit-btn {
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  background-color: #0088ff;
  color: #fff;
  font-size: 32rpx;
  border-radius: 40rpx;
  border: none;
  text-align: center;
}

.submit-btn:active {
  background-color: #0066cc;
}

/* 尺寸测量模块 */
.measurement-module {
  background-color: #fff;
  border-radius: 12rpx;
  margin: 20rpx 0;
  overflow: hidden;
}

.module-header {
  background-color: #f8f9fa;
  padding: 25rpx 30rpx;
  border-bottom: 2rpx solid #e9ecef;
}

.module-title {
  font-size: 30rpx;
  font-weight: 600;
  color: #333;
}

.measurement-module .form-item {
  margin: 0;
  border-bottom: 2rpx solid #f0f0f0;
}

.measurement-module .form-item:last-child {
  border-bottom: none;
}

.measurement-input {
  width: 150rpx;
  height: 50rpx;
  padding: 0 15rpx;
  border: 2rpx solid #e0e0e0;
  border-radius: 8rpx;
  font-size: 28rpx;
  background-color: #fff;
  text-align: right;
  margin-right: 10rpx;
}

.input-unit {
  font-size: 26rpx;
  color: #666;
  margin-right: 10rpx;
}

/* 弯轨参数模块 */
.curved-rail-module {
  background-color: #fff;
  border-radius: 12rpx;
  margin: 20rpx 0;
  overflow: hidden;
}

.curved-rail-module .module-header {
  background-color: #f0f8ff;
  padding: 25rpx 30rpx;
  border-bottom: 2rpx solid #e9ecef;
}

.curved-rail-module .module-title {
  font-size: 30rpx;
  font-weight: 600;
  color: #1890ff;
}

.curved-rail-module .form-item {
  margin: 0;
  border-bottom: 2rpx solid #f0f0f0;
}

.curved-rail-module .form-item:last-child {
  border-bottom: none;
}

/* 电动配置模块 */
.electric-config-module {
  background-color: #fff;
  border-radius: 12rpx;
  margin: 20rpx 0;
  overflow: hidden;
}

.electric-config-module .module-header {
  background-color: #fff7e6;
  padding: 25rpx 30rpx;
  border-bottom: 2rpx solid #e9ecef;
}

.electric-config-module .module-title {
  font-size: 30rpx;
  font-weight: 600;
  color: #fa8c16;
}

.electric-config-module .form-item {
  margin: 0;
  border-bottom: 2rpx solid #f0f0f0;
}

.electric-config-module .form-item:last-child {
  border-bottom: none;
}

/* 测量数据行样式 */
.measurement-data-row {
  display: flex;
  align-items: center;
  gap: 20rpx;
  flex: 1;
  justify-content: flex-end;
  margin-right: 10rpx;
}

.type-selector {
  min-width: 150rpx;
  padding: 10rpx 15rpx;
  background-color: #f5f5f5;
  border-radius: 6rpx;
  border: 2rpx solid #e0e0e0;
}

.type-text {
  font-size: 26rpx;
  color: #333;
}

.type-text.placeholder {
  color: #999;
}

.data-input {
  display: flex;
  align-items: center;
  gap: 8rpx;
}

.measurement-data-row .measurement-input {
  width: 120rpx;
  height: 50rpx;
  padding: 0 10rpx;
  border: 2rpx solid #e0e0e0;
  border-radius: 6rpx;
  font-size: 26rpx;
  background-color: #fff;
  text-align: right;
}

.measurement-data-row .input-unit {
  font-size: 24rpx;
  color: #666;
}

/* 窗帘离地高度选择样式 */
.ground-height-options {
  display: flex;
  gap: 5rpx;
  flex: 1;
  justify-content: flex-end;
  margin-right: 10rpx;
}

.option-btn-mobile {
  min-width: 160rpx;
  width: auto;
  height: 50rpx;
  padding: 0 25rpx;
  background-color: #f5f5f5;
  border: 2rpx solid #e0e0e0;
  border-radius: 8rpx;
  font-size: 22rpx;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.option-btn-mobile.active {
  background-color: #1890ff;
  border-color: #1890ff;
  color: #fff;
}

.option-btn-mobile:active {
  opacity: 0.8;
}

/* 窗幔选择样式 */
.valance-options {
  display: flex;
  gap: 5rpx;
  flex: 1;
  justify-content: flex-end;
  margin-right: 10rpx;
}

/* 内开窗选择样式 */
.inward-window-options {
  display: flex;
  gap: 5rpx;
  flex: 1;
  justify-content: flex-end;
  margin-right: 10rpx;
}

/* 特殊需求模块样式 */
.special-requirements-module {
  background-color: #fff;
  margin: 20rpx;
  border-radius: 12rpx;
  padding: 30rpx;
}

.requirement-options {
  display: flex;
  flex-wrap: wrap;
  gap: 20rpx;
  margin-bottom: 30rpx;
}

.requirement-option-btn {
  padding: 15rpx 30rpx;
  background-color: #f5f5f5;
  border: 2rpx solid #e0e0e0;
  border-radius: 8rpx;
  font-size: 26rpx;
  color: #333;
  min-width: 150rpx;
  text-align: center;
}

.requirement-option-btn:active {
  background-color: #e0e0e0;
}

.requirement-textarea {
  width: 100%;
}

.special-textarea {
  width: 100%;
  min-height: 200rpx;
  padding: 20rpx;
  border: 2rpx solid #e0e0e0;
  border-radius: 8rpx;
  font-size: 26rpx;
  line-height: 1.5;
  background-color: #fff;
  resize: none;
}

.special-textarea:focus {
  border-color: #1890ff;
  outline: none;
}

/* 移动端适配 */
@media screen and (max-width: 750rpx) {
  .ground-height-options {
    gap: 3rpx;
  }
  
  .option-btn-mobile {
    min-width: 150rpx;
    width: auto;
    font-size: 20rpx;
    padding: 0 20rpx;
    flex-shrink: 0;
  }

  .valance-options {
    gap: 3rpx;
  }

  .inward-window-options {
    gap: 3rpx;
  }
}
</style>